/**
 * Copyright 2005 The Apache Software Foundation
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.edi.util;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.edi.db.cfg.Environment;

/**
 * 工具类处理解析出来的配置文件
 * 
 * @author cya
 * 
 */
public final class FCKEditorPropertiesHelper {
	private static final Log log = LogFactory
			.getLog(FCKEditorPropertiesHelper.class);
	private static Properties propers;

	public static String getFCKProperty(String key) {
		String returnVal = "";
		if (propers == null) {
			init();
		}
		returnVal = propers.getProperty(key);
		return returnVal;
	}

	private static void init() {
		ClassLoader loader = Environment.class.getClassLoader();
		propers = new Properties();
		InputStream inStr = loader.getResourceAsStream("FCKEdit.properties");
		if (inStr == null) {
			log.error(" 找不到FCKEdit 配置文件");
			throw new RuntimeException("��ȡ�����ļ������找不到FCKEdit 配置文件");
		}
		try {
			propers.load(inStr);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} finally {
			try {
				inStr.close();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}
}
